/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.util.pointValues;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Class representing DoublePointValues
 * @author Roque, Marcos, Samir, Flavio, Jamile
 * @since Aug 2, 2005
 */
public class DoublePointValues extends PointValues  implements Serializable{
    
	private static final long serialVersionUID = 1L;
    
    private ArrayList<Double> doublePointValue;
    
    /**Constructs a DoublePointValues.*/
    public DoublePointValues() {
        doublePointValue = new ArrayList<Double>();
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.pointValues.PointValues#getPointValue()
     */
    public ArrayList<Double> getPointValue(){
    	return this.doublePointValue;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#getDoublePointValue()
     */
    public ArrayList<Double> getDoublePointValue() {
        return this.doublePointValue;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#getIntPointValue()
     */
    public ArrayList<Integer> getIntPointValue() {
    	ArrayList<Integer> aux = new ArrayList<Integer>();
    	for(int i=0; i<doublePointValue.size(); i++) {
        	aux.set(i, this.getIntPointValue(i));
        }
        return aux;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#getBooleanPointValue()
     */
    public ArrayList<Boolean> getBooleanPointValue() {
        // TODO Auto-generated method stub
        return null;
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.pointValues.PointValues#getPointValue(int)
     */
    public Double getPointValue(int i) {
        return this.doublePointValue.get(i);
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#getDoublePointValue(int)
     */
    public double getDoublePointValue(int i) {
        return (double)this.doublePointValue.get(i);
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#getIntPointValue(int)
     */
    public int getIntPointValue(int i) {
        return (int)(double)doublePointValue.get(i);
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#getBooleanPointValue(int)
     */
    public boolean getBooleanPointValue(int i) {
        return false;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#setPointValueAsDouble(double[])
     */
	public void setPointValueAsDouble(ArrayList<Double> dpv) {
        this.doublePointValue = dpv;
        
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#setPointValueAsInt(int[])
     */
    public void setPointValueAsInt(ArrayList<Integer> ipv) {
    	ArrayList<Double> aux = new ArrayList<Double>();
        for(int i=0; i<doublePointValue.size(); i++) {
        	aux.set(i, (double)(Integer) ipv.get(i));
    	}
    	this.doublePointValue=aux;   
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#setPointValueAsBoolean(boolean[])
     */
    public void setPointValueAsBoolean(ArrayList<Boolean> bpv) {}

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#setPointValueAsDouble(int, double)
     */
    public void setPointValueAsDouble(int i, double d) {
        this.doublePointValue.set(i, d);
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#setPointValueAsInt(int, int)
     */
    public void setPointValueAsInt(int i, int integer) {
        this.doublePointValue.set(i, (double)integer);
        
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#setPointValueAsBoolean(int, boolean)
     */
    public void setPointValueAsBoolean(int i, boolean b) {}
    
    /** Adds a double at position i of the double[] of Point Values.
	*@param d The double to add.
	*/
    public void addDoublePointValue(int i, double d) {
        this.doublePointValue.add(i,d);
    }

	public ArrayList<String> getStringPointValue() {
		// TODO Auto-generated method stub
		return null;
	}

	public String getStringPointValue(int i) {
		// TODO Auto-generated method stub
		return null;
	}

	public void setPointValueAsString(ArrayList<String> spv) {
		// TODO Auto-generated method stub
		
	}

	public void setPointValueAsString(int i, String s) {
		// TODO Auto-generated method stub
		
	}
	
	/* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#addPointValue(double d)
     */
	public void addPointValue(double d) {
		this.doublePointValue.add(d);
	}

	/* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#addPointValue(int integer)
     */
	public void addPointValue(int integer) {
		this.doublePointValue.add((double)integer);
	}

	/* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#addPointValue(boolean b)
     */
	public void addPointValue(boolean b) {
		// TODO Auto-generated method stub
	}

	/* (non-Javadoc)
     * @see br.ufmg.dees.insane.util.PointValues#addPointValue(String s)
     */
	public void addPointValue(String s) {
		Double aux = Double.parseDouble(s);
		this.doublePointValue.add(aux);
	}

	public int getSize() {
		return this.doublePointValue.size();
	}
	
	public void add(DoublePointValues dpv){
		for (int i = 0; i < this.getDoublePointValue().size(); i++) {
			double pv = this.getDoublePointValue(i);
			pv+=dpv.getDoublePointValue(i);
			this.setPointValueAsDouble(i,pv);
		}
	}
	
	public void set(DoublePointValues dpv){
		for (int i = 0; i < this.getDoublePointValue().size(); i++) {
			double pv=dpv.getDoublePointValue(i);
			this.setPointValueAsDouble(i,pv);
		}
	}
	
	public void scale(double a){
		for (int i = 0; i < this.getDoublePointValue().size(); i++) {
			double pv = this.getDoublePointValue(i);
			pv=pv*a;
			this.setPointValueAsDouble(i,pv);
		}
	}

}
